<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    992. Delete Columns to Make Sorted II
   </h1>
   <p>
    We are given an array&nbsp;
    <code>
     A
    </code>
    of
    <code>
     N
    </code>
    lowercase letter strings, all of the same length.
   </p>
   <p>
    Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices.
   </p>
   <p>
    For example, if we have an array
    <code>
     A = ["abcdef","uvwxyz"]
    </code>
    and deletion indices
    <code>
     {0, 2, 3}
    </code>
    , then the final array after deletions is
    <code>
     ["bef","vyz"]
    </code>
    .
   </p>
   <p>
    Suppose we chose a set of deletion indices
    <code>
     D
    </code>
    such that after deletions, the final array has its elements in
    <strong>
     lexicographic
    </strong>
    order (
    <code>
     A[0] &lt;= A[1] &lt;= A[2] ... &lt;= A[A.length - 1]
    </code>
    ).
   </p>
   <p>
    Return the minimum possible value of
    <code>
     D.length
    </code>
    .
   </p>
   <p>
    &nbsp;
   </p>
   <div>
    <div>
     <ol>
     </ol>
    </div>
   </div>
   <div>
    <p>
     <strong>
      Example 1:
     </strong>
    </p>
    <pre>
<strong>Input: </strong><span id="example-input-1-1">["ca","bb","ac"]</span>
<strong>Output: </strong><span id="example-output-1">1</span>
<strong>Explanation: </strong>
After deleting the first column, A = ["a", "b", "c"].
Now A is in lexicographic order (ie. A[0] &lt;= A[1] &lt;= A[2]).
We require at least 1 deletion since initially A was not in lexicographic order, so the answer is 1.
</pre>
    <div>
     <p>
      <strong>
       Example 2:
      </strong>
     </p>
     <pre>
<strong>Input: </strong><span>["xc","yb","za"]</span>
<strong>Output: </strong><span id="example-output-2">0</span>
<strong>Explanation: </strong>
A is already in lexicographic order, so we don't need to delete anything.
Note that the rows of A are not necessarily in lexicographic order:
ie. it is NOT necessarily true that (A[0][0] &lt;= A[0][1] &lt;= ...)
</pre>
     <div>
      <p>
       <strong>
        Example 3:
       </strong>
      </p>
      <pre>
<strong>Input: </strong><span id="example-input-3-1">["zyx","wvu","tsr"]</span>
<strong>Output: </strong><span id="example-output-3">3</span>
<strong>Explanation: </strong>
We have to delete every column.
</pre>
      <p>
       &nbsp;
      </p>
      <div>
       <div>
        <p>
         <strong>
          Note:
         </strong>
        </p>
        <ol>
         <li>
          <code>
           1 &lt;= A.length &lt;= 100
          </code>
         </li>
         <li>
          <code>
           1 &lt;= A[i].length &lt;= 100
          </code>
         </li>
        </ol>
       </div>
      </div>
     </div>
    </div>
   </div>
  </div>
  <div>
   <h1 class="question_title">
    992. 删列造序 II
   </h1>
   <p>
    给定由&nbsp;
    <code>
     N
    </code>
    &nbsp;个小写字母字符串组成的数组&nbsp;
    <code>
     A
    </code>
    ，其中每个字符串长度相等。
   </p>
   <p>
    选取一个删除索引序列，对于&nbsp;
    <code>
     A
    </code>
    &nbsp;中的每个字符串，删除对应每个索引处的字符。
   </p>
   <p>
    比如，有&nbsp;
    <code>
     A = ["abcdef", "uvwxyz"]
    </code>
    ，删除索引序列&nbsp;
    <code>
     {0, 2, 3}
    </code>
    ，删除后&nbsp;
    <code>
     A
    </code>
    &nbsp;为
    <code>
     ["bef", "vyz"]
    </code>
    。
   </p>
   <p>
    假设，我们选择了一组删除索引&nbsp;
    <code>
     D
    </code>
    ，那么在执行删除操作之后，最终得到的数组的元素是按
    <strong>
     字典序
    </strong>
    （
    <code>
     A[0] &lt;= A[1] &lt;= A[2] ... &lt;= A[A.length - 1]
    </code>
    ）排列的，然后请你返回&nbsp;
    <code>
     D.length
    </code>
    &nbsp;的最小可能值。
   </p>
   <p>
    &nbsp;
   </p>
   <ol>
   </ol>
   <p>
    <strong>
     示例 1：
    </strong>
   </p>
   <pre><strong>输入：</strong>["ca","bb","ac"]
<strong>输出：</strong>1
<strong>解释： </strong>
删除第一列后，A = ["a", "b", "c"]。
现在 A 中元素是按字典排列的 (即，A[0] &lt;= A[1] &lt;= A[2])。
我们至少需要进行 1 次删除，因为最初 A 不是按字典序排列的，所以答案是 1。
</pre>
   <p>
    <strong>
     示例 2：
    </strong>
   </p>
   <pre><strong>输入：</strong>["xc","yb","za"]
<strong>输出：</strong>0
<strong>解释：</strong>
A 的列已经是按字典序排列了，所以我们不需要删除任何东西。
注意 A 的行不需要按字典序排列。
也就是说，A[0][0] &lt;= A[0][1] &lt;= ... 不一定成立。
</pre>
   <p>
    <strong>
     示例 3：
    </strong>
   </p>
   <pre><strong>输入：</strong>["zyx","wvu","tsr"]
<strong>输出：</strong>3
<strong>解释：</strong>
我们必须删掉每一列。
</pre>
   <p>
    &nbsp;
   </p>
   <p>
    <strong>
     提示：
    </strong>
   </p>
   <ol>
    <li>
     <code>
      1 &lt;= A.length &lt;= 100
     </code>
    </li>
    <li>
     <code>
      1 &lt;= A[i].length &lt;= 100
     </code>
    </li>
   </ol>
  </div>
 </body>
</html>